package com.kotlin.mvpdemo.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewbinding.ViewBinding;

/**
 * author : fang.zhang
 * e-mail : initzf@126.com
 * date   : 2020/6/6
 * desc   : 建议所有的activity 都继承这个BaseActivity
 */
public abstract class BaseActivity<V extends BaseView, T extends BasePresenter<V>, VB extends ViewBinding> extends AppCompatActivity implements BaseView {

    protected abstract T getPresenter();

    protected abstract int getLayoutId();

    protected abstract VB getViewBind();

    protected VB mViewBinding;

    public T mPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mViewBinding = getViewBind();
        setContentView(mViewBinding.getRoot());
        mPresenter = getPresenter();
        mPresenter.onAttach((V) this, this);
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mViewBinding = null;
    }
}
